package HomeWork20241215.Car;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Car[] cars = new Car[3];

        for (int i = 0; i < cars.length; i++) {
            System.out.println("请输入第 " + (i + 1) + " 辆车的信息：");
            System.out.print("品牌: ");
            String brand = scanner.nextLine();
            System.out.print("价格: ");
            double price = scanner.nextDouble();
            // 读取换行符
            scanner.nextLine();
            System.out.print("颜色: ");
            String color = scanner.nextLine();

            cars[i] = new Car(brand, price, color);
        }

        System.out.println("\n您输入的汽车信息如下：");
        for (Car car : cars) {
            System.out.println(car.toString());
        }
    }
}
